package com.liao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liao.bean.Log;
import com.liao.bean.result.Msg;
import com.liao.bean.result.PageResult;
import com.liao.dao.LogDao;
import com.liao.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl  implements LogService {

    @Autowired
    private LogDao logDao;

    @Override
    public PageResult<Log> queryLogListByPage(Integer currentPage, Integer pageSize, String orderId) throws Exception {
        PageHelper.startPage(currentPage,pageSize);
        //查询所有菜单
        List<Log> logList = logDao.selectLogListLikeLogName(orderId);
        PageInfo<Log> pageInfo = new PageInfo<>(logList);
        return new PageResult<>(0, Msg.LOG_QUERY_SUCCESS,pageInfo.getTotal(),pageInfo.getList());
    }

    @Override
    public void addLog(Log log) throws Exception {
        logDao.addLog(log);
    }

    @Override
    public void editLog(Log log) throws Exception {
        logDao.updateLog(log);
    }

    @Override
    public void deleteLog(String logId) throws Exception {
        logDao.deleteLog(logId);
    }
}
